import { Controller, Get, Query, Param } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import type { IPaginationResponse, IAuditLog } from '@nbase/shared';
import { AuditLogService } from './audit-log.service';
import type { QueryAuditLogDto } from './dto/query-audit-log.dto';

/**
 * 审计日志控制器
 *
 * 审计日志只可查询，不可删除（保证审计记录的完整性和可追溯性）
 */
@ApiTags('审计日志')
@ApiBearerAuth('JWT-auth')
@Controller('system/audit-log')
export class AuditLogController {
  constructor(private readonly auditLogService: AuditLogService) {}

  /**
   * 分页查询审计日志
   */
  @Get()
  @ApiOperation({ summary: '分页查询审计日志' })
  findPage(@Query() dto: QueryAuditLogDto): Promise<IPaginationResponse<IAuditLog>> {
    return this.auditLogService.findPage(dto);
  }

  /**
   * 获取审计日志详情
   */
  @Get(':id')
  @ApiOperation({ summary: '获取审计日志详情' })
  findOne(@Param('id') id: string): Promise<IAuditLog> {
    return this.auditLogService.findById(id);
  }
}

